package com.jiulan.hearthearing.ui.heart.adapter;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.jiulan.hearthearing.R;
import com.jiulan.hearthearing.ui.heart.model.HeartModel;
import com.shehuan.niv.NiceImageView;

import java.util.List;

public class HeartLiveAdapter extends BaseQuickAdapter<HeartModel.DataBean.ClassLiveBean, BaseViewHolder> {
    private List<HeartModel.DataBean.ClassLiveBean> data;

    public HeartLiveAdapter(List<HeartModel.DataBean.ClassLiveBean> data) {
        super(R.layout.item_heart_live, data);
        this.data = data;
    }

    @Override
    public int getItemCount() {
        if (data.size() > 0) {
            return 1;
        }
        return 0;
    }

    @Override
    protected void convert(BaseViewHolder helper, HeartModel.DataBean.ClassLiveBean item) {
        NiceImageView nivPic = helper.getView(R.id.nivPic);
        Glide.with(mContext).load(item.getLecturer().getPic()).into(nivPic);
        helper.setText(R.id.tvTitle, item.getTitle());
        helper.setText(R.id.tvContent, item.getShort_title());
        helper.setText(R.id.tvAuthor, item.getLecturer().getName() + "·" + item.getLecturer().getTitle());
        helper.setText(R.id.tvPrice, String.valueOf(item.getAdd_time()));
        helper.setText(R.id.tvCheck, String.valueOf(item.getBuy_num()) + "人已预约");
    }
}
